#include "Pyramid.h"
#include <iostream>
//#include "../Games/MyGame.h"

Pyramid::Pyramid(int maxFrequency, std::string name) :
		GameEntity(maxFrequency, name)
{
	POINT3D topCorner = {0.0,2.0,0.0};
	POINT3D bottomCorner1 = {1.0,0.0,1.0};
	POINT3D bottomCorner2 = {1.0,0.0,-1.0};
	POINT3D bottomCorner3 = {-1.0,0.0,1.0};
	POINT3D bottomCorner4 = {-1.0,0.0,-1.0};
	PYRAMIDMESH pyramidMesh;
	pyramidMesh.topCorner = topCorner;
	pyramidMesh.bottomCorner1 = bottomCorner1;
	pyramidMesh.bottomCorner2 = bottomCorner2;
	pyramidMesh.bottomCorner3 = bottomCorner3;
	pyramidMesh.bottomCorner4 = bottomCorner4;
	_mesh = pyramidMesh;

	COLOR color = {1,1,1};
	setColor(color);

	_colorState = COLORWHITE;
	_orientationState = DEFAULT;
}

Pyramid::~Pyramid()
{
}

void Pyramid::draw()
{	
	/*GameEngine::Instance()->getRenderer()->translate(getPosition());
	GameEngine::Instance()->getRenderer()->rotate(getOrientation()); // Rotate The Pyramid On It's Y Axis
	GameEngine::Instance()->getRenderer()->drawTriangle(_mesh.topCorner, _mesh.bottomCorner1, _mesh.bottomCorner2, getColor());
	GameEngine::Instance()->getRenderer()->drawTriangle(_mesh.topCorner, _mesh.bottomCorner2, _mesh.bottomCorner3, getColor());
	GameEngine::Instance()->getRenderer()->drawTriangle(_mesh.topCorner, _mesh.bottomCorner3, _mesh.bottomCorner4, getColor());
	GameEngine::Instance()->getRenderer()->drawTriangle(_mesh.topCorner, _mesh.bottomCorner4, _mesh.bottomCorner1, getColor());
	GameEngine::Instance()->getRenderer()->drawRectangle(_mesh.bottomCorner1, _mesh.bottomCorner2, _mesh.bottomCorner3, _mesh.bottomCorner4, getColor());*/
}

void Pyramid::actualUpdate(int timePassed)
{
	switch(_orientationState)
	{
		case DEFAULT:			break;

		case XROTATIONINCTEN:	//chane rotation degree to 10
								//change rotationvector to (0,1,0)
								{ORIENTATION tempOrientation = {10.0,0.0,1.0,0.0};
								setOrientation(tempOrientation);}
								break;
	}
	switch(_colorState)
	{
		case COLORRED:	{COLOR tempColor = {1,0,0};
						setColor(tempColor);}
						break;
		case COLORBLUE:	{COLOR tempColor = {0,0,1};
						setColor(tempColor);}
						break;
	}
	//if state of me is turning left do something
	//rotation += (rotationspeed * (timePassed));
}

void Pyramid::onKeyPressed(int key)
{
	switch(key)
	{
		case '1':	_orientationState = XROTATIONINCTEN;
					break;
		case '2':	_colorState = COLORRED;
					break;
		case '3':	_colorState = COLORBLUE;
					break;
	}
}

void Pyramid::onKeyReleased(int key){}			//If a key is released, this function is called

void Pyramid::onMouseMoved(int xcoord, int ycoord){}		//If a mouseIsMoved, this function is called
void Pyramid::onMouseClicked(int xcoord, int ycoord){}	//If a mouseIsClicked, this function is called
void Pyramid::onMouseScrolled(int xcoord, int ycoord, int distance){}	//If a mouseIsScrolled, this function is called

void Pyramid::reset(){}

int Pyramid::getType() {
	return PYRAMID;
}